using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace SecondLevelCaching.Data.Models.Mapping
  {
      public class InvoiceMap : EntityTypeConfiguration<Invoice>
      {
          public InvoiceMap()
          {
              // Primary Key
              this.HasKey(t => new { t.CustomerName, t.Salesperson, t.OrderID, t.ShipperName, t.ProductID, t.ProductName, t.UnitPrice, t.Quantity, t.Discount });
  
              // Properties
              this.Property(t => t.ShipName)
                  .HasMaxLength(40);
  
              this.Property(t => t.ShipAddress)
                  .HasMaxLength(60);
  
              this.Property(t => t.ShipCity)
                  .HasMaxLength(15);
  
              this.Property(t => t.ShipRegion)
                  .HasMaxLength(15);
  
              this.Property(t => t.ShipPostalCode)
                  .HasMaxLength(10);
  
              this.Property(t => t.ShipCountry)
                  .HasMaxLength(15);
  
              this.Property(t => t.CustomerID)
                  .IsFixedLength()
                  .HasMaxLength(5);
  
              this.Property(t => t.CustomerName)
                  .IsRequired()
                  .HasMaxLength(40);
  
              this.Property(t => t.Address)
                  .HasMaxLength(60);
  
              this.Property(t => t.City)
                  .HasMaxLength(15);
  
              this.Property(t => t.Region)
                  .HasMaxLength(15);
  
              this.Property(t => t.PostalCode)
                  .HasMaxLength(10);
  
              this.Property(t => t.Country)
                  .HasMaxLength(15);
  
              this.Property(t => t.Salesperson)
                  .IsRequired()
                  .HasMaxLength(31);
  
              this.Property(t => t.OrderID)
                  .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
  
              this.Property(t => t.ShipperName)
                  .IsRequired()
                  .HasMaxLength(40);
  
              this.Property(t => t.ProductID)
                  .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
  
              this.Property(t => t.ProductName)
                  .IsRequired()
                  .HasMaxLength(40);
  
              this.Property(t => t.UnitPrice)
                  .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
  
              this.Property(t => t.Quantity)
                  .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
  
              // Table & Column Mappings
              this.ToTable("Invoices");
              this.Property(t => t.ShipName).HasColumnName("ShipName");
              this.Property(t => t.ShipAddress).HasColumnName("ShipAddress");
              this.Property(t => t.ShipCity).HasColumnName("ShipCity");
              this.Property(t => t.ShipRegion).HasColumnName("ShipRegion");
              this.Property(t => t.ShipPostalCode).HasColumnName("ShipPostalCode");
              this.Property(t => t.ShipCountry).HasColumnName("ShipCountry");
              this.Property(t => t.CustomerID).HasColumnName("CustomerID");
              this.Property(t => t.CustomerName).HasColumnName("CustomerName");
              this.Property(t => t.Address).HasColumnName("Address");
              this.Property(t => t.City).HasColumnName("City");
              this.Property(t => t.Region).HasColumnName("Region");
              this.Property(t => t.PostalCode).HasColumnName("PostalCode");
              this.Property(t => t.Country).HasColumnName("Country");
              this.Property(t => t.Salesperson).HasColumnName("Salesperson");
              this.Property(t => t.OrderID).HasColumnName("OrderID");
              this.Property(t => t.OrderDate).HasColumnName("OrderDate");
              this.Property(t => t.RequiredDate).HasColumnName("RequiredDate");
              this.Property(t => t.ShippedDate).HasColumnName("ShippedDate");
              this.Property(t => t.ShipperName).HasColumnName("ShipperName");
              this.Property(t => t.ProductID).HasColumnName("ProductID");
              this.Property(t => t.ProductName).HasColumnName("ProductName");
              this.Property(t => t.UnitPrice).HasColumnName("UnitPrice");
              this.Property(t => t.Quantity).HasColumnName("Quantity");
              this.Property(t => t.Discount).HasColumnName("Discount");
              this.Property(t => t.ExtendedPrice).HasColumnName("ExtendedPrice");
              this.Property(t => t.Freight).HasColumnName("Freight");
          }
      }
  }